package com.googlecode.maurersmarbles;

import java.util.Comparator;

public class CardComparator implements Comparator<Card> {

	@Override
	public int compare(Card lhs, Card rhs) {

		if (lhs == null && rhs == null) {
			return 0;
		}
		else if (lhs == null && rhs != null) {
			return -1;
		}
		else if (lhs != null && rhs == null) {
			return 1;
		}

		if (lhs.getId() == rhs.getId()) {
			return lhs.getSuit() < rhs.getSuit() ? -1 : 1;
		}

		return lhs.getId() < rhs.getId() ? -1 : 1;

	}

}
